/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package demo;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;
import com.jfinal.template.Engine;
import com.sun.swing.internal.plaf.metal.resources.metal;

import controller.Usercontroller;
import controller.Indexcontroller;
import controller.Upfilecontroller;
import controller.Uploadcontroller;

import model.Upfile;
import model.Upload;
import model.User;

/**
 *
 * @author Lx
 */
public class DemoConfig extends JFinalConfig {

    public void configConstant(Constants me) {
        me.setViewType(ViewType.JSP);
        PropKit.use("config.properties"); //得到文件并读取（此处为读取数据库文件所用）
//      me.setBaseUploadPath("/up/");
    }

    public void configRoute(Routes me) {
        me.add("/", Indexcontroller.class);
        me.add("/user", Usercontroller.class);
        me.add("/upload", Uploadcontroller.class);
        me.add("/upfile", Upfilecontroller.class);

    }

    public void configEngine(Engine me) {

    }

    public void configPlugin(Plugins me) {
        C3p0Plugin c3p0Plugin = new C3p0Plugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));
        ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
        arp.setShowSql(true);
        arp.addMapping("user", User.class);  //表名·model类
        arp.addMapping("file", Upload.class);
        arp.addMapping("file", Upfile.class);
        me.add(c3p0Plugin);
        me.add(arp);
    }

    public void configInterceptor(Interceptors me) {

    }

    public void configHandler(Handlers me) {

    }

}
